package com.aaa.entity.result;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author ：陈凯歌
 * @date ：Created in 2021/1/9 15:00
 * @description：
 * @modified By：
 * @version:
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("响应结果")
public class Result {
    @ApiModelProperty("状态码")
    private Integer code;
    @ApiModelProperty("提示语句")
    private String msg;
    @ApiModelProperty("返回结果集")
    private Object data;

    /**
     * create by: 陈凯歌
     * description: 成功且无返回值
     * create time: 2021/1/19 9:27
     * 
      * @Param: null
     * @return 
     */
    
    public static Result succeed(String msg){

        return new Result(1, msg, null);
    }
    /**
     * create by: 陈凯歌
     * description: 成功且有返回值
     * create time: 2021/1/19 9:28
     * 
      * @Param: null
     * @return 
     */
    
    public static Result succeed(Object data){

        return new Result(1, "成功", data);
    }

    /**
     * create by: 陈凯歌
     * description: 错误响应
     * create time: 2021/1/19 9:28
     * 
      * @Param: null
     * @return 
     */
    
    public static Result error(String msg){
        return new Result(2, msg, null);
    }
}